﻿// $Id$
/*! \file
 * \brief Definition of Northwind.DomainModel.Product.
 *
 * \author $Author$
 * \date $Date$
 * \version $Revision$
 */

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Serialization;
using Salamanca.DataAccess;
using Salamanca.DataAccess.Collections;
using Salamanca.DataRules;
#if (!NET_CF)
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
#endif

namespace Northwind.DomainModel
{



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial interface IProductContainer
    {
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial interface IProductMapper:
        IDataMapper
    {
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ///////////////////////////////////////////////////////////////////////////

#if (!NET_CF)
    [Serializable]
    [DataObject]
#endif
    public partial class Product:
        DomainEntity<Product.PrimaryKey, Product.DataTransfer>
    {

        /// <summary />
#if (!NET_CF)
        [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
#endif
        public partial class PrimaryKey:
            PrimaryKey<int>
        {

            /// <summary />
            public PrimaryKey():
                base()
            {
            }

            /// <summary />
            public PrimaryKey(int key):
                base(key)
            {
            }

        }

        /// <summary />
        [SoapType("ProductData", "http://www.codeplex.com/salamanca/northwind/domainmodel/")]
        [XmlType("ProductData", Namespace="http://www.codeplex.com/salamanca/northwind/domainmodel/")]
#if (!NET_CF)
        [Serializable]
        [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
#endif
        public partial class DataTransfer:
            IDataTransferObject
        {
        }

        /// <summary />
        public Product():
            base()
        {
        }

        /// <summary />
        public Product(DataMapperCollection dataMappers):
            base(dataMappers)
        {
        }

#if (!NET_CF)
        /// <summary />
        protected Product(SerializationInfo info, StreamingContext context):
            base(info, context)
        {
        }
#endif

        /// <summary />
        protected override void OnSaving(PersistenceEventArgs e)
        {
            if (_Category!=null)
              ((IPersistent)_Category).Save(e.Context);
            if (_Supplier!=null)
              ((IPersistent)_Supplier).Save(e.Context);

            base.OnSaving(e);
        }

        /// <summary />
        public override void Load(bool lazyLoad)
        {
            base.Load(lazyLoad);

            if (!IsNew)
            {
                _LoadCategory(lazyLoad);
                _LoadSupplier(lazyLoad);
            }
        }

        /// <summary />
        public override void Unload()
        {
            base.Unload();

            _Category=null;
            _Supplier=null;
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public Category Category
        {
            get
            {
                return _CategoryProperty;
            }
            set
            {
                if (_CategoryProperty!=value)
                {
                    _CategoryProperty=value;
                    RaisePropertyChanged("Category");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public Supplier Supplier
        {
            get
            {
                return _SupplierProperty;
            }
            set
            {
                if (_SupplierProperty!=value)
                {
                    _SupplierProperty=value;
                    RaisePropertyChanged("Supplier");
                }
            }
        }

        /// <summary />
        [StringLengthRule(40)]
        [NotNullRule]
#if (!NET_CF)
        [DataObjectField(false, false, false)]
#endif
        public string ProductName
        {
            get
            {
                return _ProductNameProperty;
            }
            set
            {
                if (_ProductNameProperty!=value)
                {
                    _ProductNameProperty=value;
                    RaisePropertyChanged("ProductName");
                }
            }
        }

        /// <summary />
        [StringLengthRule(20)]
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public string QuantityPerUnit
        {
            get
            {
                return _QuantityPerUnitProperty;
            }
            set
            {
                if (_QuantityPerUnitProperty!=value)
                {
                    _QuantityPerUnitProperty=value;
                    RaisePropertyChanged("QuantityPerUnit");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public decimal? UnitPrice
        {
            get
            {
                return _UnitPriceProperty;
            }
            set
            {
                if (_UnitPriceProperty!=value)
                {
                    _UnitPriceProperty=value;
                    RaisePropertyChanged("UnitPrice");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public short? UnitsInStock
        {
            get
            {
                return _UnitsInStockProperty;
            }
            set
            {
                if (_UnitsInStockProperty!=value)
                {
                    _UnitsInStockProperty=value;
                    RaisePropertyChanged("UnitsInStock");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public short? UnitsOnOrder
        {
            get
            {
                return _UnitsOnOrderProperty;
            }
            set
            {
                if (_UnitsOnOrderProperty!=value)
                {
                    _UnitsOnOrderProperty=value;
                    RaisePropertyChanged("UnitsOnOrder");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public short? ReorderLevel
        {
            get
            {
                return _ReorderLevelProperty;
            }
            set
            {
                if (_ReorderLevelProperty!=value)
                {
                    _ReorderLevelProperty=value;
                    RaisePropertyChanged("ReorderLevel");
                }
            }
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectField(false, false, true)]
#endif
        public bool? Discontinued
        {
            get
            {
                return _DiscontinuedProperty;
            }
            set
            {
                if (_DiscontinuedProperty!=value)
                {
                    _DiscontinuedProperty=value;
                    RaisePropertyChanged("Discontinued");
                }
            }
        }

    }
}
